//index.js
//获取应用实例
const app = getApp();

Page({
  data: {
    background: ['green', 'red', 'yellow'],
    indicatorDots: true,
    vertical: false,
    autoplay: true,
    interval: 3000,
    duration: 1200,
    swipers: [
      {
        image: '../../res/image/banner/banner1.jpg'
      },
      {
        image: '../../res/image/banner/banner2.jpg'
      },
      {
        image: '../../res/image/banner/banner3.jpg'
      }
    ],
    grids:[
      {
        image:'../../res/image/icon/relu.png',
        title:'规章预案',
        url:'../grid1_rule/grid1_rule'
      },
      {
        image: '../../res/image/icon/publish.png',
        title: '预警发布',
        url:'../grid2_publish/grid2_publish'
      },
      {
        image: '../../res/image/icon/guide.png',
        title: '详情指南',
        url: '../grid3_guide_category/grid3_guide_category'
      },
      {
        image: '../../res/image/icon/chat.png',
        title: '音频视频',
        url: '../grid4_chat/grid4_chat'
      },
      {
        image: '../../res/image/icon/live.png',
        title: '现场直播',
        url: '../grid5_live/grid5_live'
      },
      {
        image: '../../res/image/icon/report.png',
        title: '事件通报',
        url: '../grid6_report/grid6_report'
      },
      {
        image: '../../res/image/icon/list.png',
        title: '联络名单',
        url: '../grid7_connect/grid7_connect'
      },
      {
        image: '../../res/image/icon/mail.png',
        title: '短信群发',
        url: '../grid8_mails/grid8_mails'
      },
      {
        image: '../../res/image/icon/my.png',
        title: '我的信息',
        url: '../grid9_info/grid9_info'
      }
    ],
    zero:0
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    });
  },
  onLoad: function() {
    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      });
    } else if (this.data.canIUse) {
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        });
      };
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo;
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          });
        }
      });
    }
  },
  getUserInfo: function(e) {
    console.log(e);
    app.globalData.userInfo = e.detail.userInfo;
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    });
  }
});
